# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=repro-env
pkgver=0.3.2
pkgrel=1
pkgdesc="Dependency lockfiles for reproducible build environments"
url='https://github.com/kpcyrd/repro-env'
arch=('loong64' 'x86_64')
license=('GPL-3.0-or-later')
depends=('podman' 'catatonit')
makedepends=('cargo' 'scdoc')
options=(!lto)
source=(https://github.com/kpcyrd/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        https://github.com/kpcyrd/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz.asc)
validpgpkeys=("64B13F7117D6E07D661BBCE0FE763A64F5E54FD6")
sha256sums=('d1e6b7e335d8fe6dd673f0311a6b3cb399ee5b1c667662fb542fae548637fff4'
            'SKIP')
b2sums=('3bfc865c6555f809767218706f8f578d22a3891333a1ddf00351e950010f868f74e6d75914cc9f11e9bbcfe33d37e083ceeabb4f0a4255ca7e9eb1d65cd63e21'
        'SKIP')

prepare() {
  cd "${pkgname}-${pkgver}"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd ${pkgname}-${pkgver}
  cargo build --frozen --release
  make docs
}

check() {
  cd ${pkgname}-${pkgver}
  cargo test --frozen
  target/release/repro-env --help
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/repro-env

  install -Dm 644 -t "${pkgdir}/usr/share/man/man1" \
    docs/repro-env.1

  # install completions
  install -d "${pkgdir}/usr/share/bash-completion/completions" \
             "${pkgdir}/usr/share/zsh/site-functions" \
             "${pkgdir}/usr/share/fish/vendor_completions.d"
  "${pkgdir}/usr/bin/${pkgname}" completions bash > "${pkgdir}/usr/share/bash-completion/completions/${pkgname}"
  "${pkgdir}/usr/bin/${pkgname}" completions zsh > "${pkgdir}/usr/share/zsh/site-functions/_${pkgname}"
  "${pkgdir}/usr/bin/${pkgname}" completions fish > "${pkgdir}/usr/share/fish/vendor_completions.d/${pkgname}.fish"
}

# vim: ts=2 sw=2 et:
